package com.example.a_java.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.a_java.dto.CustomerVisitDTO;
import com.example.a_java.entity.CustVisitRecord;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 客户回访记录Mapper接口
 */
@Mapper
public interface CustVisitRecordMapper extends BaseMapper<CustVisitRecord> {
    
    /**
     * 查询客户回访记录列表
     * @param page 分页参数
     * @param custId 客户ID
     * @return 回访记录DTO列表
     */
    @Select("SELECT " +
            "cvr.visit_id AS id, " +
            "cvr.cust_id AS custId, " +
            "cvr.visit_time AS visitTime, " +
            "cvr.method, " +
            "cvr.visitor, " +
            "cvr.content, " +
            "cvr.feedback, " +
            "cvr.next_visit_time AS nextVisitTime, " +
            "cvr.create_time AS createTime " +
            "FROM cust_visit_record cvr " +
            "WHERE cvr.is_deleted = 0 AND cvr.cust_id = #{custId} " +
            "ORDER BY cvr.visit_time DESC")
    IPage<CustomerVisitDTO> selectVisitList(Page<CustomerVisitDTO> page, @Param("custId") Long custId);
} 
